#include "main.h"

unsigned int Hour = 0;
unsigned int Minute = 0;
unsigned int Second = 0;
unsigned char key = 1;
void main()
{

	LCD_Init();
	Timer0Init();
	while (1)
	{
		unsigned char A=key_Count();
			if(A!=0)
			key = A;
			if (key==1)
			{
				P2_1 = ~P2_1;
			}
			if(key==2)
			{
				P2_2 = ~P2_2;
			}
		

		LCD_ShowString(1, 1, "Time:");
		LCD_ShowNum(2, 1, Hour, 2);
		LCD_ShowChar(2, 3, ':');
		LCD_ShowNum(3, 4, Minute, 2);
		LCD_ShowChar(3, 6, ':');
		LCD_ShowNum(4, 7, Second, 2);
		LCD_ShowNum(1, 8, key, 2);
		LCD_ShowNum(1,10,A,2);
	}
}

void Timer_Cut() interrupt 1
{

	static unsigned int Count = 0;
	// TL0 = 0xF5;		//设置定时初值
	// TH0 = 0xFF;		//设置定时初值
	TL0 = 0x66; // 设置定时初值
	TH0 = 0xFC; // 设置定时初值
	Count++;
	if (Count == 10)
	{
		if(key==1)
		Second++;
		if (Second == 100)
		{
			Minute++;
			Second = 0;
		}
		if (Minute == 60)
		{
			Hour++;
			Minute = 0;
		}
		if (Hour == 24)
		{
			Hour = 0;
		}
		Count = 0;
	}
}